home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / ENDAPP.ZIP / README.TXT < prev   
Encoding:
Text File  |  1996-02-29  |  2.8 KB  |  79 lines

  1. TEndApp Component
  2.  
  3. by 
  4.  
  5. Dave Nottage
  6.  
  7. of
  8.  
  9. ALIEN Computing
  10. PO Box 45
  11. CALLINGTON   SA  5254
  12. AUSTRALIA
  13.  
  14. This component is freeware. Please feel free to distribute in any
  15. legal manner you wish, as long as you include the following files:
  16.  
  17. README.TXT (this file, but you already knew that)
  18. ENDAPP.DCU 
  19. ENDAPP.DCR (It's got the really ace component bitmap. Well, allllrighty then!!!)
  20.  
  21. I haven't included the source, 'coz someone is bound to vandalize my
  22. code, and I don't want to be responsible for someone elses mistakes.
  23. ie If you find a bug with this, it's my fault, so please tell me about it.
  24. Having said that, I will not take any responsibility for any loss of
  25. business, pecuniary loss, loss of files, loss of data, loss of hair or
  26. body parts caused by this component.
  27.  
  28. If you want to tell me something, and don't like snail mail, send something
  29. on comp.lang.pascal.delphi.components. I read the newsgroup fairly often, and don't
  30. have my own personal 'net mail account yet. (I've gotta get one soon!!!!).
  31.  
  32. Enough of that, now about the component!!!!!!!
  33.  
  34. TEndApp makes it easier to trap those annoying messages that your Delphi
  35. app would otherwise miss, specifically when some wally closes Windows down without 
  36. saving their work.
  37.  
  38. Its only properties are Name and Tag.
  39.  
  40. It's power lies in its two events:
  41.  
  42. OnQueryEndSession traps the WM_QUERYENDSESSION message that Windows sends
  43. all applications when Windows wants to close down. OnQueryEndSession passes a boolean 
  44. parameter called OKEnd, which is initially set to False. If you really want your app 
  45. to end, set it to True eg:
  46.  
  47. procedure TForm1.EndApp1QueryEndSession(var OKEnd:boolean);
  48. begin
  49.   if FileIsntSavedYet then
  50.     if MessageDlg('Windows is shutting down & you havent saved!'#13
  51.                   'Yes=Save and Exit, No=Stop this insanity',
  52.                    mtConfirmation,[mbYesNo],0)=mrYes then
  53.       begin
  54.         SaveBeforeItsTooLate;
  55.         OKEnd:=True { Bite the bullet and agree to close down }
  56.       end
  57.     else
  58.       OKEnd:=False { No, go away, I'm not ready }
  59. end;
  60.  
  61. OnEndSession traps the WM_ENDSESSION message, which is sent after WM_QUERYENDSESSION.
  62. The boolean parameter Ending tells you whether or not all apps agreed to shut down. eg:
  63.  
  64. procedure TForm1.EndApp1EndSession(Ending:boolean);
  65. begin
  66.   if Ending then
  67.     { Too late now... }
  68.     SaveWithoutAskingBecauseItsEndingAnyway
  69. end;
  70.  
  71. This component is a result of queries vented on numerous newsgroups, mail lists,
  72. street corners etc. I hope you find it as satisfying as I did when I got the damn thing
  73. to work.
  74.  
  75. Install the component in the usual way, or the unusual way if you can find one. To
  76. alleviate tab overpopulation, the component installs on the 'Samples' palette. 
  77. What...you mean you've already got 1001 components on your 'Samples' palette? Oh, well..
  78.  
  79.